package com.li.test.model2;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 - 消息队列的配置类
 */
@Configuration
public class RabbitConfigModel2 {

    @Bean
    public Queue createNewQueue1() {
        return new Queue("queue1");
    }
    @Bean
    public Queue createNewQueue2() {
        return new Queue("queue2");
    }

    @Bean
    public FanoutExchange createFanoutExchange() {
        return new FanoutExchange("fanout1");
    }

    @Bean
    public Binding binding1(Queue createNewQueue1, FanoutExchange createFanoutExchange) {
        return BindingBuilder.bind(createNewQueue1).to(createFanoutExchange);
    }
    @Bean
    public Binding binding2(Queue createNewQueue2, FanoutExchange createFanoutExchange) {
        return BindingBuilder.bind(createNewQueue2).to(createFanoutExchange);
    }




    /**
     * 消息序列化成JSON字符串
     */
//    @Bean
//    public MessageConverter messageConverter() {
//        return new Jackson2JsonMessageConverter();
//    }
}